package com.shuai.controller;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.shuai.model.User;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author shuaihong-coding
 * @date 2025/10/2
 * @className UserController
 */
@RestController
@RequestMapping("/user")
public class UserController {

    private static final ObjectMapper objectMapper = new ObjectMapper();

    /**
     * 获取用户信息
     */
    @RequestMapping("/getUserInfo")
    public String getUserInfo() throws JsonProcessingException {
        User user = User.builder()
                .username("帅宏")
                .age(21)
                .gender("男")
                .money(100.0)
                .build();
        String userStrJson = objectMapper.writeValueAsString(user);
        System.out.println("userStrJson ： "+userStrJson);
        return userStrJson;
    }
}
